const app = getApp()
Page({
  data: {
    imgs:{
      detail1:app.globalData.apiImgBase2+'detail1.png',
      detail2:app.globalData.apiImgBase2+'detail2.png',
      brand1:'../../img/test.png',
      imgBase:app.globalData.apiImgBase2
    },
    cityList:['上海','广州','深圳','杭州','北京','成都','曼谷','纽约','东京','首尔'],
    detailType:0,
    detail:{},
    imgBase:app.globalData.apiImgBase1,
    showMask:false,
    modalStr:'',
    page:0
  },
  onLoad: function (options) {
    this.getDetail(options.type)
    this.setData({
      detailType:options.type,
      page:options.page
    })
    this.getGrade()
  },
  getDetail(id){
    console.log(id)
    let data = ''
    switch(id){
      case '0':
        data = 'YuTopClub'
        break;
      case '1':
        data = 'YuHighLevelFriends'
        break;
      case '2':
        data = 'YuHotelGift'
        break;
      case '3':
        data = 'YuBoat'
        break;
      case '4':
        data = 'YuSecretary'
        break;
    }
    console.log(data)
    app.request('api/getDicConfig?dicTypeCode='+data).then(res=>{
      console.log(res)
      wx.hideLoading()
      if(res.success){
        this.setData({
          detail:res.content
        })
      }else{
        console.log(res.message)
      }
    })
  },
  getGrade(){
    app.request('ugc/getAccountInfo').then(res=>{
      console.log(res)
      wx.hideLoading()
      if(res.success){
        this.setData({
          grade:res.content.gradeId
        })
      }else{
        console.log(res.message)
      }
    })
  },
  toggleMask(e){
    if(this.data.showMask){
      this.setData({
        showMask:false,
        modalStr:''
      })
    }else{
      this.setData({
        showMask:true,
        modalStr:e.currentTarget.dataset.str
      })
    }
  },
  back(){
    // let pages = getCurrentPages();
    // let prevPage = pages[pages.length - 2];
    // console.log(prevPage)
    // if(prevPage.route=='pages/member/member'){
    //   prevPage.setData({
    //     cardType:this.data.cardType
    //   })
    // }
    // if(this.data.page==0){
    //   wx.navigateBack()
    // }else{
    //   wx.switchTab({
    //     url:'../member/member'
    //   })
    // }
    wx.navigateBack()
  },
  bindCharges(){
    wx.navigateTo({
      url:'../recharge/recharge'
    })
  },
  bindContact(){
    wx.makePhoneCall({
      phoneNumber: '4009669295'
    })
  }
})